<?php
    session_start();
    include('top.php');
?>
    <style>
        #ui_div_border {
            visibility: hidden;
        }
    </style>
    <div class="home-body">
        <?php include('info.php'); ?>
            <div class="home-container">
                <div class="home-side-by-side-no">1.选择招生对象</div>
                <div class="home-side-by-side-yes">2.填写个人信息</div>
                <div class="home-side-by-side-no">3.选择专业</div>
                <div class="home-side-by-side-no">4.报名确认</div>
            </div>

            <div class="home-container-body">
                <div class="home-side-by-side-start" style="width: 300px;">
                    <h2 class="home-title">填写个人信息</h2>
                    <div>
                        <form method="post" id="myForm" action="update.php?action=my">
                            <table width="100%">
                                <tr class="home-table">
                                    <td class="home-my-td">考生姓名</td>
                                    <td class="home-my-td-fff">
                                        <input type="text" name="exnumber" readonly="readonly" class="index_input" value="<?php echo $row['name']; ?>"> 注册成功不可修改</td>
                                </tr>
                                <tr class="home-table">
                                    <td class="home-my-td">证件号码</td>
                                    <td class="home-my-td-fff">
                                        <input type="text" name="exnumber" readonly="readonly" class="index_input" value="<?php echo $row['number']; ?>"> 注册成功不可修改</td>
                                </tr>
                                <tr class="home-table">
                                    <td class="home-my-td">准考证号</td>
                                    <td class="home-my-td-fff">
                                        <input type="text" name="exnumber" readonly="readonly" class="index_input" value="<?php echo $row['exnumber']; ?>"> 准考证号由注册时生成</td>
                                </tr>
                                <tr class="home-table">
                                    <td colspan="2" class="home-my-td" align="center">
                                        <a class="upload" href="upload.php" target="_blank">点击上传资料</a>
                                    </td>
                                </tr>
                                <tr class="home-table">
                                    <td class="home-my-td">上传照片</td>
                                    <td class="home-my-td-fff">
                                        <input type="text" name="photo" class="index_input" value="<?php if (empty($row['photo'])) {} else { echo $row['photo']; } ?>"> 照片请使用白底或者蓝底且容量不少于2M的jpg、png图片。
                                    </td>
                                </tr>
                                <tr class="home-table">
                                    <td class="home-my-td">身份证正面</td>
                                    <td class="home-my-td-fff">
                                        <input type="text" name="cardz" class="index_input" value="<?php if (empty($row['cardz'])) {} else { echo $row['cardz']; } ?>"> 请清晰拍摄或者扫描身份证正面
                                    </td>
                                </tr>
                                <tr class="home-table">
                                    <td class="home-my-td">身份证反面</td>
                                    <td class="home-my-td-fff">
                                        <input type="text" name="cardf" class="index_input" value="<?php if (empty($row['cardf'])) {} else { echo $row['cardf']; } ?>"> 请清晰拍摄或者扫描身份证反面
                                    </td>
                                </tr>
                                <tr class="home-table">
                                    <td class="home-my-td">报名申请表</td>
                                    <td class="home-my-td-fff">
                                        <input type="text" name="sqb" class="index_input" value="<?php if (empty($row['sqb'])) {} else { echo $row['sqb']; } ?>"> 请清晰拍摄或者扫描报名申请表
                                    </td>
                                </tr>
                                <tr class="home-table">
                                    <td class="home-my-td">考生诚信承诺书</td>
                                    <td class="home-my-td-fff">
                                        <input type="text" name="cns" class="index_input" value="<?php if (empty($row['cns'])) {} else { echo $row['cns']; } ?>"> 请清晰拍摄或者扫描考生诚信承诺书
                                    </td>
                                </tr>
                                <tr class="home-table">
                                    <td class="home-my-td">学历验证报告单</td>
                                    <td class="home-my-td-fff">
                                        <input type="text" name="bgd" class="index_input" value="<?php if (empty($row['bgd'])) {} else { echo $row['bgd']; } ?>"> 请清晰拍摄或者扫描学历验证报告单
                                    </td>
                                </tr>
                                <tr class="home-table">
                                    <td class="home-my-td">本科阶段成绩单</td>
                                    <td class="home-my-td-fff">
                                        <input type="text" name="cjd" class="index_input" value="<?php if (empty($row['cjd'])) {} else { echo $row['cjd']; } ?>"> 请仔细了解本校是否需要本科阶段成绩单，不需要可留空。
                                    </td>
                                    <tr class="home-table">
                                        <td class="home-my-td">邮寄地址</td>
                                        <td class="home-my-td-fff">
                                            <input type="text" name="address" class="index_input" value="<?php if (empty($row['address'])) {} else { echo $row['address']; } ?>"> 邮寄地址请填写能够用于收到录取通知书的真实地址
                                        </td>
                                    </tr>
                                    <tr class="home-table">
                                        <td class="home-my-td">毕业院校</td>
                                        <td class="home-my-td-fff">
                                            <input type="text" name="school" class="index_input" value="<?php if (empty($row['school'])) {} else { echo $row['school']; } ?>"> 请真实填写毕业院校
                                        </td>
                                    </tr>
                                    <tr class="home-table">
                                        <td class="home-my-td">本科专业</td>
                                        <td class="home-my-td-fff">
                                            <input type="text" name="bkzy" class="index_input" value="<?php if (empty($row['bkzy'])) {} else { echo $row['bkzy']; } ?>"> 请真实填写本科专业全称
                                        </td>
                                    </tr>
                                    <tr class="home-table">
                                        <td class="home-my-td">门类、专业类</td>
                                        <td class="home-my-td-fff">
                                            <?php if (empty($row['zylb'])) {
                                    include('mlzyl.php');
                                } else { ?>
                                                <input type="text" name="zylb" class="index_input" value="<?php echo $row['zylb']; ?>">
                                                <?php } ?>
                                                    请选择本科专业类别全称，例如法学类、设计学类等。

                                                    <a href="http://www.moe.gov.cn/srcsite/A08/moe_1034/s4930/202304/W020230419336779992203.pdf" target="_blank" class="upload">点击查询</a>
                                        </td>
                                    </tr>
                                    <tr class="home-table">
                                        <td class="home-my-td">毕业年份</td>
                                        <td class="home-my-td-fff">
                                            <input type="text" name="years" class="index_input" value="<?php if (empty($row['years'])) {} else { echo $row['years']; } ?>"> 请填写：2024、2023、2022、2021。
                                        </td>
                                    </tr>
                                    <tr class="home-table">
                                        <td class="home-my-td">学历证书号</td>
                                        <td class="home-my-td-fff">
                                            <input type="text" name="xlzs" class="index_input" value="<?php if (empty($row['xlzs'])) {} else { echo $row['xlzs']; } ?>"> 18位，已取得毕业证书学生必填。
                                        </td>
                                    </tr>
                                    <tr class="home-table">
                                        <td class="home-my-td">学位证书号</td>
                                        <td class="home-my-td-fff">
                                            <input type="text" name="xwzs" class="index_input" value="<?php if (empty($row['xwzs'])) {} else { echo $row['xwzs']; } ?>"> 16位，已取得毕业证书学生必填。
                                        </td>
                                    </tr>
                                    <tr class="home-table">
                                        <td class="home-my-td">毕业证书图片</td>
                                        <td class="home-my-td-fff">
                                            <input type="text" name="xlzsphoto" class="index_input" value="<?php if (empty($row['xlzsphoto'])) {} else { echo $row['xlzsphoto']; } ?>"> 请清晰拍摄或者扫描毕业证书
                                        </td>
                                    </tr>
                                    <tr class="home-table">
                                        <td class="home-my-td">学位证书图片</td>
                                        <td class="home-my-td-fff">
                                            <input type="text" name="xwzsphoto" class="index_input" value="<?php if (empty($row['xwzsphoto'])) {} else { echo $row['xwzsphoto']; } ?>"> 请清晰拍摄或者扫描学位证书
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" align="center">
                                            <p>以上信息（除准考证外）确保真实，如填写错误或者无效，一切后果由考生承担！</p>
                                            <div class="ui_div_border" id="ui_div_border">
                                                <table class="ui_border ui_state_visible ui_state_focus ui_state_lock" id="alert">
                                                    <tbody>
                                                        <tr>
                                                            <td class="ui_lt"></td>
                                                            <td class="ui_t"></td>
                                                            <td class="ui_rt"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="ui_l"></td>
                                                            <td class="ui_c">
                                                                <div class="ui_inner">
                                                                    <table class="ui_dialog">
                                                                        <tbody>
                                                                            <tr>
                                                                                <td colspan="2">
                                                                                    <div class="ui_title_bar">
                                                                                        <div class="ui_title" unselectable="on" style="cursor: move;">警告</div>
                                                                                        <div class="ui_title_buttons"><a class="ui_close" href="javascript:void(0);" title="关闭(esc键)" style="display: inline-block;">×</a></div>
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                                <td class="ui_icon" style=""><img src="/static/img/alert.gif" class="ui_icon_bg"></td>
                                                                                <td class="ui_main" style="width: 200px; height: auto;">
                                                                                    <div id="selectResult"></div>
                                                                                </td>
                                                                            </tr>
                                                                            <tr>
                                                                                <td colspan="2">
                                                                                    <div class="ui_buttons" style="">
                                                                                        <input type="button" value="确定" class="ui_state_highlight" onclick="location.reload();">
                                                                                    </div>
                                                                                </td>
                                                                            </tr>
                                                                        </tbody>
                                                                    </table>
                                                                </div>
                                                            </td>
                                                            <td class="ui_r"></td>
                                                        </tr>
                                                        <tr>
                                                            <td class="ui_lb"></td>
                                                            <td class="ui_b"></td>
                                                            <td class="ui_rb" style="cursor: auto;"></td>
                                                        </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                            <p style="margin-top: 36px;">
                                                <input id="next" class="my-home-submit" type="submit" value="保存&提交信息">
                                                <a class="my-home-submit" href="select-home.php">专业选择</a>
                                            </p>
                                        </td>
                                    </tr>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
    </div>
    <script type="text/javascript" src="static/js/jquery-3.6.0.min.js"></script>
    <script type="text/javascript">
        document.addEventListener('DOMContentLoaded', function() {
            const nextButton = document.getElementById('next');
            const uiDivBorder = document.getElementById('ui_div_border');

            nextButton.addEventListener('click', function() {
                uiDivBorder.style.visibility = 'visible';
            });
        });
        $(document).ready(function() {
            $('#myForm').on('submit', function(e) {
                e.preventDefault();
                var formData = $(this).serialize();

                $.ajax({
                    url: 'update.php?action=my',
                    type: 'POST',
                    data: formData,
                    success: function(response) {
                        $('#selectResult').empty();
                        $('#selectResult').html(response);
                    },
                    error: function(error) {
                        console.log(error);
                        $('#selectResult').html('失败，请稍后再试。');
                    }
                });
            });
        });
        
        const closeButton = document.querySelector('.ui_close');
        const confirmButton = document.querySelector('.ui_state_highlight');
        const uiDivBorder = document.getElementById('ui_div_border');
        
        closeButton.addEventListener('click', function() {
            uiDivBorder.style.visibility = 'hidden';
        });
        
        confirmButton.addEventListener('click', function() {
            uiDivBorder.style.visibility = 'hidden';
        });
    </script>
    <?php include('bottom.php'); ?>